package com.haiheng.module_main.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.TextView
import com.haiheng.module_main.R

/**
 *
 * @Des:
 * @Author: hwz
 * @Date:2024/9/10 0010
 * @Version: 1.0
 */
class CustomSpinnerAdapter(context: Context, resource: Int, textViewResourceId: Int, objects: Array<String>)
    : ArrayAdapter<String>(context, resource, textViewResourceId, objects) {

    override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View {
        var view = convertView
        if (view == null) {
            val inflater = LayoutInflater.from(context)
            view = inflater.inflate(R.layout.spinner_dropdown_item, parent, false)
        }

        val textView = view?.findViewById<TextView>(R.id.text)
        textView?.text = getItem(position)

        return view!!
    }
}